﻿using System;
using System.Collections.Generic;
using System.Text;

using NetStsAdm;

namespace NetStsAdm.Commands
{
    /// <summary>
    /// Help command. Returns the help and some info about this tool
    /// </summary>
    internal class HelpCommand : ICommand
    {
        public int Execute(Dictionary<string, string> keyValues, out string Output)
        {
            Output = HelpCommand.GetHelp();
            return 0;
        }

        internal static string GetHelp()
        {
            StringBuilder sb = new StringBuilder("netstsadm usage : ");
            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine("   -h <show this help>");
            sb.AppendLine("   -config <open the configuration file in 'notepad'>");
            sb.AppendLine();
            sb.AppendLine("   -TargetURL <specify the destination environment>");
            sb.AppendLine("   -TargetLogin <specify the user login to on the target environment>");
            sb.AppendLine("   -TargetPwd <pecify the user password to on the target environment>");
            sb.AppendLine("      Followed by a standard stsadm command, without 'stsadm'.");
            sb.AppendLine();
            sb.AppendLine("      Note that the three parameters TargetURL, TargetLogin and TargerPwd");
            sb.AppendLine("      can be specified in a configuration file (run 'netstsadm -config')");
            sb.AppendLine();
            sb.AppendLine("      If those params are in both the config file and the command line, ");
            sb.AppendLine("      command line values win.");
            sb.AppendLine();
            sb.AppendLine(" Sample : ");
            sb.AppendLine("   * netstsadm -TargetURL http://SharePoint -TargetLogin [User] -TargetPwd [Pass]");
            sb.AppendLine("               -o enumsubwebs -url http://SharePoint");
            sb.AppendLine("   * netstsadm -o enumssp -all");
            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine(" Important : make sure the NetStsAdmService service is running on the destination environment.");
            sb.AppendLine();
            sb.AppendLine(" Julien Chomarat - SharePointOfView - http://www.SharePointOfView.fr/Julien");

            return sb.ToString();
        }
    }
}
